using System;
using System.Collections.Generic;
using System.Text;
using EntityLayer;
using System.Data;
using DataAccessLayer;

namespace DataLayer
{
    public class datParameters
    {
        public datParameters()
        {
        }

        #region  Code Factory Generated Methods

        public void UpdateParametersByParameterId(entParameters parEntParameters, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pParameterId", parEntParameters.ParameterId);

            insDbParamCollection.Add("@pParameterName", parEntParameters.ParameterName);
            insDbParamCollection.Add("@pParameterValue", parEntParameters.ParameterValue);
            insDbParamCollection.Add("@pControlTypeId", parEntParameters.ControlTypeId);
            parDbConnector.ExecuteNonQuery("UpdateParametersByParameterId", insDbParamCollection);
        }
        public DataTable SelectParameters(DbConnector parDbConnector)
        {

            return parDbConnector.ExecuteDataTable("SelectParameters", null);
        }
        public void SelectParametersByParameterId(entParameters parEntParameters, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pParameterId", parEntParameters.ParameterId);
            DataTable insDataTable = new DataTable();
            insDataTable = parDbConnector.ExecuteDataTable("SelectParametersByParameterId", insDbParamCollection);
            if (insDataTable.Rows.Count > 0)
            {
                if (insDataTable.Rows[0]["ParameterId"] != DBNull.Value)
                {
                    parEntParameters.ParameterId = Convert.ToInt32(insDataTable.Rows[0]["ParameterId"]);
                }
                if (insDataTable.Rows[0]["ParameterName"] != DBNull.Value)
                {
                    parEntParameters.ParameterName = insDataTable.Rows[0]["ParameterName"].ToString();
                }
                if (insDataTable.Rows[0]["ParameterValue"] != DBNull.Value)
                {
                    parEntParameters.ParameterValue = insDataTable.Rows[0]["ParameterValue"].ToString();
                }
                if (insDataTable.Rows[0]["ControlTypeId"] != DBNull.Value)
                {
                    parEntParameters.ControlTypeId = Convert.ToInt32(insDataTable.Rows[0]["ControlTypeId"]);
                }
            }
        }

        #endregion
    }
}